package com.itheima.mapper1;

import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author wuyiqiang
 * @2022/6/19 19:47
 */
@Mapper
public interface OrdersMapper {

    /**
     * 新增订单
     *
     * @param order
     */
    @Insert("insert into orders values (#{id},#{number},#{status},#{userId},#{addressBookId},#{orderTime},#{checkoutTime},#{payMethod},#{amount}," +
            "#{remark},#{username},#{phone},#{address},#{consignee})")
    void submit(Order order);

    /**
     * 分页查询
     *
     * @param page
     * @param pageSize
     * @return
     */
    @Select("select * from orders  order by order_time desc limit #{page},#{pageSize} ")
    List<Order> page(Integer page, Integer pageSize);

    /**
     * 查询订单总条数
     *
     * @return
     */
    @Select("select count(*) from orders")
    Integer selectAll();
}
